//
//  ACEQuestionSubjectViewController.m
//  ACE
//
//  Created by zhangtao on 2018/8/13.
//  Copyright © 2018年 zt.td. All rights reserved.
//

#import "ACEQuestionSubjectViewController.h"
#import "ACEQuestionsSubjectCell.h"
#import "ACEQuestionAnswerController.h"
@interface ACEQuestionSubjectViewController ()

@end

@implementation ACEQuestionSubjectViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = _subjectName;
    [self.tableView registerNib:[UINib nibWithNibName:@"ACEQuestionsSubjectCell" bundle:nil] forCellReuseIdentifier:@"cell"];
}

-(void)startAnswer{
    ACEQuestionAnswerController *answer = [[ACEQuestionAnswerController alloc]init];
    [self.navigationController pushViewController:answer animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 15;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *str = @"卡洛斯打给你了亲火";
    CGSize size = [ACEPublicTool textViewTextFont:[UIFont systemFontOfSize:17] andText:str Weight:ACEWidth-80.00 andHeight:1000.00];
    return size.height+40;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 80;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    return 30;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    UILabel *lab = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, ACEWidth, 30)];
    lab.backgroundColor =[UIColor whiteColor];
    lab.text = @"Mutile choise";
    return lab;
}

-(UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ACEWidth, 80)];
    UIButton *btn = [[UIButton alloc]initWithFrame:CGRectMake(ACEWidth/2-100, view.center.y-25, 200, 50)];
    [btn setBackgroundColor:deepGreen];
    [btn setTitle:@"重做" forState:UIControlStateNormal];
    btn.layer.cornerRadius = 25;
    [btn addTarget:self action:@selector(startAnswer) forControlEvents:UIControlEventTouchUpInside];
    [view addSubview:btn];
    return view;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    ACEQuestionsSubjectCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 
    cell.subjectLab.text = @"卡洛斯打给你了亲火";
    // Configure the cell...
    
    return cell;
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    } else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
